Repository navigation
fix(glm4_moe): accept Transformers 5.22 router tuple - #72
Merged
Merged
Conversation
Transformers 5.22 routers return (router_logits, topk_weights,
topk_indices). LinearGlm4MoeMoE and LinearGlm4MoeLiteMoE passed that
tuple straight into route_tokens_to_experts(), which calls .sigmoid(),
so the first MoE layer raised:
AttributeError: 'tuple' object has no attribute 'sigmoid'
Unwrap the tuple to the raw logits before Defuser's grouped top-k
selection. The router's precomputed top-k is intentionally discarded so
the routing math stays byte-identical across Transformers versions.
Bump Defuser to 0.0.31 for the GPTQModel version gate.
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
Defuser 0.0.31 fixes the GLM-4.5/4.6/4.7 and GLM-4.7-Flash replacement MoE blocks, which passed the Transformers 5.22 router tuple (router_logits, topk_weights, topk_indices) into route_tokens_to_experts() and crashed on .sigmoid(). Raise the floor to defuser>=0.0.31 and remove the local gptqmodel/utils/defuser_compat.py shim now that the fix is upstream. Update the Tenstorrent manifest pin, version-gate tests, and the Transformers 5.22 compatibility docs. Depends on ModelCloud/Defuser#72 and the 0.0.31 release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Defuser's GLM-4.x replacement MoE blocks crash on Transformers 5.22 because the router now returns
(router_logits, topk_weights, topk_indices)andLinearGlm4MoeMoE/LinearGlm4MoeLiteMoEpassed that tuple straight intoroute_tokens_to_experts(), which calls.sigmoid():This is the upstream fix requested by the reviewer note in ModelCloud/GPTQModel#4055 (issue ModelCloud/GPTQModel#4040, section F).
Fix
route_tokens_to_experts()now accepts either the raw logits tensor or the Transformers 5.22 router tuple and unwrapsrouter_output[0].forward()passes the router output through unchanged; the block no longer assumes a tensor.0.0.30->0.0.31so dependents can gate on the release.Tests
test_glm4_route_tokens_accepts_tuple_and_tensor_equivalently(bothglm4_moeandglm4_moe_lite): tuple and tensor inputs produce bit-identical indices and weights.test_defused_glm4_model_forward_accepts_router_tuple(both families): full defused model forward succeeds and produces finite logits.test_glm4_moe_defused_forward_matches_fused_mathandtest_glm4_moe_lite_defused_forward_matches_fused_mathnow pass; they previously failed with the tuple error.Full suite: 151 passed / 21 failed, identical to
main's 145 passed / 23 failed except for the two GLM-4 defused-forward tests this fixes. The remaining failures are pre-existing onmainunder the local Transformers build (unrelated registry cases).Release dependency
GPTQModel will raise its
defuserfloor to>=0.0.31in a paired PR once this release is published. The current GPTQModeldefuser_compatshim is removed by that PR.